package logic

import (
	"context"
	"video/model/mysql"

	"video/videorpc/internal/svc"
	"video/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoShowLogic {
	return &VideoShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoShowLogic) VideoShow(in *videorpc.VideoShowRequest) (*videorpc.VideoShowResponse, error) {
	// todo: add your logic here and delete this line

	var video mysql.Video

	err := video.VideoShow(mysql.DB, in.VideoId)
	if err != nil {
		return nil, err
	}

	return &videorpc.VideoShowResponse{
		VideoId: int64(video.ID),
		Title:   video.Title,
		Image:   video.Image,
		Author:  video.Author,
		Desc:    video.Desc,
	}, nil
}
